-- round_self_recover4
-- created by dengc
-- 每回合回复，回复量按楼层计算

return {
    apply = function(prop, baseValue)
        return math.modf(prop[3] * baseVAlue / 1000);
    end,

    -- 每回合触发
    trigger = function(who, prop, arg)
        local attrib = tostring(prop[2]);

        -- 目前只有hp、mp
        assert(attrib == "hp" or attrib == "mp");

        local max = who:getMaxHp();
        local curr = who:getHp();
        if attrib == "mp" then
            max = who:getMaxMp();
            curr = who:getMp();
        end

        -- 回复量
        local layer = DungeonM.currentLayer();
        local value = FormulaM.invoke("CALA_ROUND_RECOVER4_VALUE", layer, max, curr);

        if who.type == OBJECT_TYPE_USER then
            BonusM.doBonus({ 2, attrib, value, }, "round_self_recover4");
        else
            who:addAttrib(attrib, value);
        end

        return value;
    end,

    record = function(target, prop, path)
        return false;
    end
};
